package com.example.game_dafangdaxie.activity;

import android.content.Context;
import android.os.Bundle;
import android.os.PowerManager;

import androidx.appcompat.app.AppCompatActivity;

import com.example.game_dafangdaxie.View.AiView;
import com.example.game_dafangdaxie.View.ChessView;

public class GameActivity extends AppCompatActivity {

    private static int flag;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Bundle bundle=getIntent().getBundleExtra("viewCode");
         flag = bundle.getInt("code");
    }

    @Override
    protected void onResume() {
        super.onResume();
        if(flag==2){
            ChessView chessView=new ChessView(this,isScreenOn(this));
            setContentView(chessView);
        }else if(flag==1){
            AiView chessView=new AiView(this,isScreenOn(this));
            setContentView(chessView);
        }


    }

    public boolean isScreenOn(Context context) {
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        if (pm.isInteractive()) {
            return true;
        }
        return false;
    }

}